﻿using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; 

namespace 干涉检查Demo
{
    public  class Msg
    {
        public static XtraMessageBoxArgs errorArgs; //错误弹窗变量
        public static XtraMessageBoxArgs tipsArgs;//提示弹窗变量       

        #region 错误+提示弹窗实现 

        /// <summary>
        /// 错误信息弹窗
        /// </summary>
        /// <param name="tipsType"></param>
        /// <param name="msg"></param>
        public static void ErrorMessageShow(string msg)
        {
            try
            {
              
                errorArgs = new XtraMessageBoxArgs//错误弹窗变量
                {
                    Text = msg,
                    Caption = "信息提示"
                };
                errorArgs.Showing += ErrorArgs_Showing; 
                XtraMessageBox.Show(errorArgs);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            
        }


        /// <summary>
        /// 信息提示弹窗
        /// </summary>
        /// <param name="tipsType"></param>
        /// <param name="msg"></param>
        public static void SelectMessageShow(string msg)
        {
            tipsArgs = new XtraMessageBoxArgs
            {
                Text = msg,
                Caption = "信息提示"
            };
            tipsArgs.Showing += Tips_Showing;
            XtraMessageBox.Show(tipsArgs);
        }


        //错误弹窗 
        public static  void  ErrorArgs_Showing(object sender, XtraMessageShowingArgs e)
        {

            //倒计时
           // errorArgs.AutoCloseOptions.Delay = 5000; 
            //按钮显示
            errorArgs.AutoCloseOptions.ShowTimerOnDefaultButton = true;
            //对应按钮显示倒计时
            errorArgs.DefaultButtonIndex = 0;

            errorArgs.Caption = "信息提示"; 
            //按钮
            errorArgs.Buttons = new DialogResult[] { DialogResult.OK };

            //错误图标  
            errorArgs.Icon = SystemIcons.Information;
             
            //消息字体
            e.Form.Appearance.Font = new Font("微软雅黑", 12);

            //'字体颜色
            e.Form.Appearance.ForeColor = Color.Black;

            e.Form.FormBorderStyle = FormBorderStyle.Fixed3D;

            //不显示眉头图标 
            e.Form.ShowIcon = true;

            e.Form.Icon = SystemIcons.Information;

            e.Form.TopMost = true;

          e.Form.StartPosition = FormStartPosition.CenterParent;

            //字体加粗
            // e.Form.Appearance.FontStyleDelta = FontStyle.Bold;
              
            foreach (object control in e.Form.Controls)
            {
                SimpleButton button = (SimpleButton)control;

                if (button != null)
                {
                    button.Appearance.FontSizeDelta = 3;
                    button.Height += Convert.ToInt32(1.5);
                    button.Width += 1;
                }
            }
        }

        //提示弹窗 
        public static void Tips_Showing(object sender, XtraMessageShowingArgs e)
        {
            //倒计时
           // tipsArgs.AutoCloseOptions.Delay = 5000;
            //按钮显示
            tipsArgs.AutoCloseOptions.ShowTimerOnDefaultButton = true;
            //对应按钮显示倒计时
            //tipsArgs.DefaultButtonIndex = 0; 
            ////按钮
           // tipsArgs.Buttons = new DialogResult[] { DialogResult.Yes,DialogResult.No};
            //错误图标  
            tipsArgs.Icon = SystemIcons.Question;

            tipsArgs.Caption = "信息提示";

            //消息字体
            e.Form.Appearance.Font = new Font("微软雅黑", 12);

            //'字体颜色
            e.Form.Appearance.ForeColor = Color.Black;

            e.Form.FormBorderStyle = FormBorderStyle.Fixed3D;

            //不显示眉头图标 
            e.Form.ShowIcon = true;

            e.Form.Icon = SystemIcons.Information;
            //字体加粗
            // e.Form.Appearance.FontStyleDelta = FontStyle.Bold;

            foreach (object control in e.Form.Controls)
            {
                SimpleButton button = (SimpleButton)control;

                if (button != null)
                {
                    button.Appearance.FontSizeDelta = 3;
                    button.Height += Convert.ToInt32(1.5);
                    button.Width += 1;
                }

            } 
        }
         

        #endregion
         
    }
     


}

